package cst.a000tyy.broadnotifytest_000tyy;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private EditText editText;
    private Button button1,button2;
    private String UNIQUE_STRING="cst.a000tyy.broadnotifytest_000tyy";

    private void init(){
        editText=(EditText)findViewById(R.id.editText);
        button1=(Button)findViewById(R.id.button);
        button2=(Button)findViewById(R.id.button2);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        button1.setOnClickListener(this);
        button2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.button:
               Intent intent=new Intent(UNIQUE_STRING);
                intent.putExtra("value1",editText.getText().toString());
                sendBroadcast(intent);
                break;
            case R.id.button2:
               MyBroadNotifyReceiver.notificationManager.cancel(1);

        }
    }
}
